<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
// 首页的路由
Route::get('/', 'PagesController@root')->name('root');

// 用户认证 等同于Auth::routes();

// 用户登录认证路由
Route::get('login', 'Auth\LoginController@showLoginForm')->name('login');
Route::post('login', 'Auth\LoginController@login');
Route::post('logout', 'Auth\LoginController@logout')->name('logout');

// 用户注册的路由
Route::get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
Route::post('register', 'Auth\RegisterController@register');

// 重置密码路由
Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
Route::post('password/reset', 'Auth\ResetPasswordController@reset');

/**
 * 用户的展示，修改，更新路由
 */

Route::resource('users', 'UsersController', ['only' => ['show', 'update', 'edit']]);
// Route::get('/users/{user}', 'UsersController@show')->name('users.show');
// Route::get('/users/{user}/edit', 'UsersController@edit')->name('users.edit');
// Route::patch('/users/{user}', 'UsersController@update')->name('users.update');



Route::resource('topics', 'TopicsController', ['only' => ['index', 'show', 'create', 'store', 'update', 'edit', 'destroy']]);

// 测试 依赖注入

/**
 * 目前采用的是依赖注入的方式来传入一个类
 * 要使用的类
 */

class Baz {}

class Bar
{
    public $baz = null;

    public function __construct(Baz $baz)
    {
        $this->baz = $baz;
    }
}

Route::get('/bar', function (Bar $bar) {
    dd($bar->baz);
});


// 测试服务容器

// app()->bind('rice', function () {
//     return new \App\Rice;
// });

app()->bind('rice', \App\Rice::class);

Route::get('rice', function (\App\Rice $rice) {

    return app()->make('foodservice')->food();
    return app()->make('riceContainer')->food();
    

    
    return app()->make('rice')->food();
    // return resolve('rice')->food();
    return $rice->name();   //App\Rice;    
    return $rice->food();

});